﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FirebirdSql.Data.FirebirdClient;
namespace University
{
   
    public partial class VYKLADACHI : University.WORKERS
    {
        static string sqlSelect = "SELECT * FROM VYKLADACHI";
        FbDataAdapter da = new FbDataAdapter(sqlSelect, con);
        DataTable dt = new DataTable();
        public VYKLADACHI()
        {
            InitializeComponent();
           
        }
        public VYKLADACHI(TreeNode node, ContextMenuStrip s, string com, int id)
            : base(node, s, com, id)
        {
            InitializeComponent();
            node_id = Convert.ToInt32(mynode.Tag.ToString());
            InitializeComponent();
            da.Fill(dt);
            bindingSource1.DataSource = dt;
            richTextBox2.DataBindings.Add("Text", bindingSource1, "NAYKOVUJ_STYPIN");
            richTextBox3.DataBindings.Add("Text", bindingSource1, "NAYKOVA_POSADA");
           bindingSource1.Filter = "UNIQUE_NO =" + node_id;
           if (com == "Remove") { Remove("VYKLADACHI"); }
       }

       public override void Remove(string name)
       {
           base.Remove(name);
       }

       public override void UpdateForm()
       {
           OpenCon();
           UpdateFild("VYKLADACHI", "NAYKOVUJ_STYPIN", richTextBox2.Text);
           UpdateFild("VYKLADACHI", "NAYKOVA_POSADA", richTextBox3.Text);
           base.UpdateForm();
       }
        public override void InsertFild(string klas)
        {
            OpenCon();
            FbCommand cmdInsert = new FbCommand("INSERT INTO VYKLADACHI(UNIQUE_NO,NAYKOVUJ_STYPIN,NAYKOVA_POSADA) VALUES(@1,@2,@3)", con);
            cmdInsert.Parameters.AddWithValue("1", textBox1.Text);
            cmdInsert.Parameters.AddWithValue("2", richTextBox2.Text);
            cmdInsert.Parameters.AddWithValue("3", richTextBox3.Text);
            cmdInsert.ExecuteNonQuery();
            base.InsertFild(klas);
        }
        private void VYKLADACHI_Load(object sender, EventArgs e)
        {

        }
    }
}